﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace ResourceBlender.Core {
    /// <summary>
    /// A template for generating resources
    /// </summary>
    public class RBTemplate : INotifyPropertyChanged {
        private int id;
        private string name,
                       fileName,
                       fileStart,
                       fileEnd,
                       fileLine;

        /// <summary>
        /// Gets or sets the ID.
        /// </summary>
        /// <value>The ID.</value>
        public int ID {
            get { return id; }
            set {
                id = value;
                OnPropertyChanged("ID");
            }
        }

        /// <summary>
        /// Gets or sets the name of the template.
        /// </summary>
        /// <value>The name of the template.</value>
        public string Name {
            get { return name; }
            set {
                name = value;
                OnPropertyChanged("Name");
            }
        }

        /// <summary>
        /// Gets or sets the template for the file name.
        /// </summary>
        /// <value>The template for the name of the file.</value>
        public string FileName {
            get { return fileName; }
            set {
                fileName = value;
                OnPropertyChanged("FileName");
            }
        }

        /// <summary>
        /// Gets or sets the template for the start of the file.
        /// </summary>
        /// <value>The template for the start of the file.</value>
        public string FileStart {
            get { return fileStart; }
            set {
                fileStart = value;
                OnPropertyChanged("FileStart");
            }
        }

        /// <summary>
        /// Gets or sets the template for the end of the file.
        /// </summary>
        /// <value>The template for the end of the file.</value>
        public string FileEnd {
            get { return fileEnd; }
            set {
                fileEnd = value;
                OnPropertyChanged("FileEnd");
            }
        }

        /// <summary>
        /// Gets or sets the template for each line in the file.
        /// </summary>
        /// <value>The template for each line in the file.</value>
        public string FileLine {
            get { return fileLine; }
            set {
                fileLine = value;
                OnPropertyChanged("FileLine");
            }
        }

        /// <summary>
        /// Initializes a new <see cref="RBTemplate"/>.
        /// </summary>
        public RBTemplate() {
            this.id = -1;
            this.name = string.Empty;
            this.fileName = string.Empty;
            this.fileStart = string.Empty;
            this.fileEnd = string.Empty;
            this.fileLine = string.Empty;
        }

        /// <summary>
        /// Initializes a new <see cref="RBTemplate"/>.
        /// </summary>
        /// <param name="id">The ID.</param>
        /// <param name="name">The name of the template.</param>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="fileStart">The file start.</param>
        /// <param name="fileEnd">The file end.</param>
        /// <param name="fileLine">The template for each line in the file.</param>
        public RBTemplate(int id, string name, string fileName, string fileStart, string fileEnd, string fileLine) {
            this.id = id;
            this.name = name;
            this.fileName = fileName;
            this.fileStart = fileStart;
            this.fileEnd = fileEnd;
            this.fileLine = fileLine;
        }

        /// <summary>
        /// Creates a deep copy of this instance.
        /// </summary>
        /// <returns></returns>
        public RBTemplate Clone() {
            RBTemplate clone = new RBTemplate(this.id, this.name, this.fileName, this.fileStart, this.fileEnd, this.fileLine);
            return clone;
        }

        public event PropertyChangedEventHandler PropertyChanged;
        protected virtual void OnPropertyChanged(string strPropertyName) {
            if(PropertyChanged != null) {
                PropertyChanged(this, new PropertyChangedEventArgs(strPropertyName));
            }
        }
    }
}
